 var currentPage=1;

 getOneAdmin2();

function getOneAdmin2() {
	$.ajax({
		url: urlcore + "/api/user/getadmin",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
				if(data.data!=null && data.data!=""){
						caigoufabu(); 
				}
			}
		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
}
var ss=0;
 function caigoufabu(){
		if(currentPage==1 || currentPage==2 || ss!=0){
			$.ajax({
 url: urlcore + "/api/wantBuy/selectList?current="+currentPage+"&userId="+uuuuid+"&sort=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss=data.data.length;
					 $.each(data.data.list,function(y,n){
					 	if(n.uptDatetime!=null){
		 var d1 = new Date(); 
  var d2 = new Date(Date.parse(n.uptDatetime));
  var dateds=1;
             if(parseInt((d1 - d2) / 60000)<60){
             	if(parseInt((d1 - d2) / 60000)<1){
             		 dateds=dateds+"分钟前更新";
             	}else{
             		 dateds=parseInt((d1 - d2) / 60000)+"分钟前更新";
             	}
             }else{
             if(parseInt((d1 - d2) / 60000)<2880){
             	     if(parseInt((d1 - d2) / 60000)<1300){
             	      dateds="今天"+d2.getHours()+":"+d2.getMinutes()+"更新"; //分+"小时前更新";
              }else{
var time=n.uptDatetime; 
var timearr=time.replace(" ",":").replace(/\:/g,"-").split("-"); 
var svns=0;
var zuotian="";
for(i=0;i<timearr.length;i++){
	svns++;
	if(svns==2){
     	zuotian+=timearr[i]+"-";
     }else if(svns==3){
     	zuotian+=timearr[i]+" ";
     }else  if(svns==4){
     	zuotian+=timearr[i]+":";
     }else if(svns==5){
     	zuotian+=timearr[i];
     }
} 
             	   dateds=zuotian+"更新";
             	     }
             }else{
var time=n.uptDatetime; 
var timearr=time.replace(" ",":").replace(/\:/g,"-").split("-"); 
var svns=0;
var genxin="";
for(i=0;i<timearr.length;i++){
	svns++;
	if(svns==2){
		genxin+=timearr[i]+"-";
	}else if(svns==3){
	 	genxin+=timearr[i]+" ";
	 }else if(svns==4){
     	genxin+=timearr[i]+":";
     }else if(svns==5){
     	genxin+=timearr[i];
     }
} 
             	dateds=genxin+"更新";
             }
              }
  
  	
					 	
			 var caigouid="<li>"+
			      '<a href="33.1.0caigou_detail.html?id='+n.id+'">';
			        if(n.status==1){  //求购成功
		caigouid+='<DIV style="position:absolute; top:0, left:0; width:400; height:300; z-index:0">'+
			'<img onerror="errorImg(this)" src="'+n.coverUrl+'"  width=400 height=300 />'+
		   '</DIV>'+
		   '<DIV style="position:absolute; top:20; left:190; width:200; height:100; text-align:center; z-index:2">'+
			'<IMG id=logo src="../images/qiugouchenggong.png"  width=400 height=300">'+
		'</DIV>';
			    }else{
			    	caigouid+='<img src="'+n.coverUrl+'"/>';
			    }
				caigouid+='<h5>'+dateds+'</h5>'+
			'</a>'+
		'</li>';
		   $("#caigouid").append(caigouid);
					 	}
					 });
					
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		}
		
	
 }
